package br.com.dao.hibernate;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;

import br.com.dao.ItemDAO;
import br.com.dao.VendaDAO;
import br.com.item.Item;
import br.com.venda.Venda;



public class HibernateVendaDao extends HibernateGenericDAO<Venda> implements VendaDAO {

	public HibernateVendaDao(Session session) {
		super(session);
		// TODO Auto-generated constructor stub
	}

	public List<String> pesquisarDescricoes(String descricao) {
		return this.getSession().createCriteria(Item.class).setProjection(Projections.distinct(Projections.property("descricao")))
				.add(Restrictions.ilike("descricao", descricao, MatchMode.ANYWHERE))
				.addOrder(Order.asc("descricao")).list();
	}

}
